%%%-------------------------------------------------------------------
%%% @author kk
%%% @copyright (C) 2024, <COMPANY>
%%% @doc
%%% 替换元组或列表中指定位置的元素，新元素作为参数和列表或元组一起传入函数内
%%% @end
%%% Created : 19. 7月 2024 15:45
%%%-------------------------------------------------------------------
-module(d9).
-author("kk").

%% API
-export([removeIndexElement/1, removeIndexElement/3]).

removeIndexElement([]) -> [].
removeIndexElement(List, Index, Num) -> removeIndexElement(List, Index, 1, Num);
removeIndexElement([], Index, I) -> [].
removeIndexElement([H | List], Index, I, Num) ->
  if
    Index /= I -> io:fwrite("list：~w index：~w ~n", [H, I]), [H | removeIndexElement(List, Index, I + 1, Num)];
    true -> [Num | List] % 替换
  end.